package pumpkin;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Random;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class PolyDemo extends JFrame{
	public static void main(String[] args){
		new PolyDemo();
	}
	
	
	
	private ArrayList<Shape> shapes = new ArrayList<Shape>();
	public PolyDemo(){
//		shapes.add(new Circle(Color.BLACK, 40));
//		shapes.add(new Triangle(Color.GREEN, 10,35,50,150,200,50));
		shapes.add(new Rectangle(Color.BLACK,400,400,0,0));
		this.buildStars(125);
		shapes.add(new Rectangle(Color.GREEN,150,400,0,250));
		shapes.add(new Circle(Color.LIGHT_GRAY,200,-75,-75));
		shapes.add(new Triangle(Color.YELLOW, 130,270,240,160,130,0));


		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		add(new Paper());
		this.setSize(400,400);
		
		this.setVisible(true);
	}
	
	public void buildStars(int MaxStars){
		System.out.println("Building Stars");
		Random r = new Random();
		for(int i = 0; i < MaxStars; i++){
			shapes.add(new Circle(Color.LIGHT_GRAY,3,r.nextInt(400), r.nextInt(300)));
		}

	}

	@SuppressWarnings("serial")
	class Paper extends JPanel{
		public void paintComponent(Graphics g)
		{
			super.paintComponents(g);
			for (Shape s: shapes){
				s.draw(g);
			}
		}
	}
	
}
